home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13998 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.4 KB  |  54 lines

  1. Newsgroups: comp.lang.c
  2. Path: netcom.com!smryan
  3. From: smryan@netcom.com (@#$%!?!)
  4. Subject: Re: C syntax question
  5. Message-ID: <smryanDponD1.5KI@netcom.com>
  6. Organization: The Programmer formerly known as S M Ryan
  7. X-Newsreader: TIN [version 1.2 PL1]
  8. References: <4ki00k$a4@mailhub.scitec.com.au>
  9. Date: Thu, 11 Apr 1996 05:31:48 GMT
  10. Sender: smryan@netcom19.netcom.com
  11.  
  12. "Doctor, it hurts when I do this!"
  13. "Then don't do it."
  14.  
  15. : This is supposedly correct C, typedef names are ignored when defining
  16. : structure members. But not when defining variables so:
  17. :       byte    byte;
  18. : is an error when not inside a structure definition. Am I correct so far?
  19.  
  20. There's a very good chance a c parser will use the same code for struct
  21. members and variable declarations. Perhaps a few flags thrown in. Unless
  22. many people do this kind of thing, that will probably not change.
  23.  
  24. :       ubyte signed                    i;
  25. :       byte unsigned                   j;
  26. :       signed ubyte                    k;
  27. :       unsigned byte                   l;
  28.  
  29. Presumably the parsers are panicking if after collected some specs, they
  30. see a typedef-name, before they peek inside the typedef. Once they do, they
  31. are probably replacing the name with definition immediately and so can
  32. handle additional specs. Since a typedef-name is not generally compatiable
  33. with signed or long, parser writer probably took the easy way.
  34.  
  35. While you are (I assume) correct in both cases, and it would be nice if you
  36. (and others) did it right, you'll be hard pressed to get anybody (except
  37. yourself) to do anything about it.
  38.  
  39. : of typedef names or type keywords in any order. This is causing a major
  40. : problem in being able to parse "byte byte;" correctly in the structure
  41. : definition. I.e. is the second occurance of "byte" supposed to be treated as
  42. : a typedef name or the member name?
  43.  
  44. With a two token lookahead, the ambiguity dissappears. The member name must
  45. be followed by "," ":" or ";". Allowing function parameter names to be
  46. typedef-names would be ambiguous: void f(signed byte), is "signed byte" an
  47. abstract or actual declarator?
  48.  
  49. -- 
  50. The Queen, amused, in quiet power,         | smryan@netcom.com  PO Box 1563
  51. will draw the son to darkenned bower.      |          Cupertino, California
  52. Her face is fair, her fragrance rare,      | (xxx)xxx-xxxx            95015
  53. with woven webs for wayward flower.        |         I don't use no smileys
  54.